package com.bit.ioc.controller;

import com.bit.ioc.config.UserConfig;
import com.bit.ioc.model.UserInfo;
import com.bit.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
public class UserController2 {


    private UserService userService;

    private UserConfig userConfig;

    private UserInfo userInfo;

    public UserController2() {
    }

    public UserController2(UserService userService) {
        this.userService = userService;
    }
//
//    @Autowired
    public UserController2(UserService userService, UserConfig userConfig) {
        this.userService = userService;
        this.userConfig = userConfig;
    }

    @Autowired
    public UserController2(UserService userService, UserConfig userConfig, @Qualifier("user1") UserInfo userInfo) {
        this.userService = userService;
        this.userConfig = userConfig;
        this.userInfo = userInfo;
    }

    public void sayHi(){
        System.out.println(userService);
        userService.doService();
        System.out.println(userInfo);
        userConfig.doConfig();
        System.out.println("UserController.sayHi....");
    }
}
